<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>合同详细信息</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">
		<link href="../../../css/task.css" rel="stylesheet" />
		<style type="text/css" scoped="scoped">
			.details_con .clum{
				margin: 0px;
			}
			table tr td{
				text-align: center;
			}
			table tr{
				border-top: 1px #ccc solid;
			}
			table tr:nth-child(1){
				border-top: none;
			}
			.mt-10{
				margin-top: 10px !important;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav"> 
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">合同详细信息</h1>
		</header>
		<div class="mui-content">
			<div class="details_con">
				
				<div class="clum">
					<span class="name">合同编号</span>
					<span  class="txt"  id="contractNo"></span>
				</div>
				<div class="clum">
					<span class="name">合同类型</span>
					<span class="txt" id="contractType"></span>
				</div>
				<div class="clum">
					<span class="name">合同子类型</span>
					<span  class="txt"  id="contractSubType"></span>
				</div>
				<div class="clum">
					<span class="name">SAP合同号</span>
					<span class="txt" id="contractSAP"></span>
				</div>
				<div class="clum">
					<span class="name">合同开始时间</span>
					<span  class="txt"  id="contractStart"></span>
				</div>
				<div class="clum">
					<span class="name">合同结束时间</span>
					<span class="txt" id="contractEnd"></span>
				</div>
				<div class="clum">
					<span class="name">合同内容</span>
					<span  class="txt"  id="contractContent"></span>
				</div>
				<div class="clum ">
					<span class="name">合同服务设置</span>
				</div>
				<table id="contractSvcSet" style="width: 100%; border: 1px solid #999; color: #999;"></table>
				<div class="clum ">
					<span class="name">合同折扣设置</span>
				</div>
				<table id="contractDiscount" style="width: 100%; border: 1px solid #999; color: #999;"></table>
			</div>
		
			<div style="height: 50px;"></div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		
	</body>
	<script type="text/javascript">
		var serviceNo,ContractNo,ContractType,ContractSubType,ContractContent,ContractSAP,ContractStart,ContractEnd,ContractSvcSet,ContractDiscount
		(function($, doc) {
			$.init();
			$.plusReady(function() {
				// 从上一个页面取值
				var self = plus.webview.currentWebview();
				 // 获取上一个页面传过来的参数并显示到页面
				serviceNo = self.serviceNo;
				getServiceContract();
			})
		}(mui, document));
		
		function getServiceContract(){
			app.showWaiting();
			ajaxGet(BASE_URL + "cc/service/annex/getServiceContractHandle", {
				"serviceNo": serviceNo,
			}, function(data){
				app.closeWaiting();
				if(data.code == 200 && data.data){
					data.data = JSON.parse(data.data)
					h("#contractNo").html(data.data.record[0].ContractNo)
					h("#contractContent").html(data.data.record[0].ContractContent)
					h("#contractSAP").html(data.data.record[0].ContractSAP)
					h("#contractEnd").html(data.data.record[0].ContractEnd)
					h("#contractStart").html(data.data.record[0].ContractStart)
					h("#contractGuid").html(data.data.record[0].ContractGuid)
					h("#contractType").html(data.data.record[0].ContractType)
					h("#contractSubType").html(data.data.record[0].ContractSubType)
					/**
					 * 服务设置
					 */
					if(data.data.record[0].ContractSvcSet){
						data.data.record[0].ContractSvcSet = JSON.parse(data.data.record[0].ContractSvcSet)
						var list = data.data.record[0].ContractSvcSet
						var html =	`<tr>
										<th>服务类型</th>
										<th>服务子类型</th>
										<th>是否不限次数</th>
										<th>服务次数</th>
										<th>剩余次数</th>
									</tr>`
						if(list.length>0){
							for(var i = 0 ; i < list.length; i++){
								html += `<tr>
											<td>${list[i].Servicetype}</td>
											<td>${list[i].Servicesubtype}</td>
											<td>${list[i].Limitless}</td>
											<td>${list[i].SvcCnt}</td>
											<td>${list[i].ReCnt}</td>
										</tr>`
							}
						}
						h('#contractSvcSet').html(html)
					}else{
						h('#contractSvcSet').html(html)
					}
					/**
					 * 折扣设置
					 */
					if(data.data.record[0].ContractDiscount){
						data.data.record[0].ContractDiscount = JSON.parse(data.data.record[0].ContractDiscount)
						var list = data.data.record[0].ContractDiscount
						var html =	`<tr>
										<th>折扣类型</th>
										<th>折扣信息（%）</th>
									</tr>`
						if(list.length>0){
							for(var i = 0 ; i < list.length; i++){
								html += `<tr>
											<td>${list[i].Discounttype}</td>
											<td>${list[i].Discounts}</td>
										</tr>`
							}
						}
						h('#contractDiscount').html(html)
					}else{
						h('#contractDiscount').html(html)
					}
				}else{
					app.closeWaiting();
				}
				console.log(JSON.stringify(data))
			},function(errMsg){
				
			})
		}
	</script>
</html>
